﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InfonavaEye.model
{
    /// <summary>
    /// 自动识别的参数
    /// </summary>
    public class AutoStartParams
    {
        public static readonly string NAIL_MAP_KEY_FORMAT="{0}_{1}_{2}";

        /// <summary>
        /// 钉盒模型名字
        /// </summary>
        public string BoxModelName { get; set; }

        /// <summary>
        /// 钉盒模型实体
        /// </summary>
        public BoxModel BoxModel { get; set; }

        /// <summary>
        /// 显示在主界面上的钉子集合
        /// </summary>

        public List<Nail> NailList { get; set; }

        /// <summary>
        /// 选择钉盒模板时选中的钉子的字典
        /// </summary>
        public Dictionary<String, Nail> TemplateNailMap { get; set; }

        private List<Nail> templateNailList = null;

        /// <summary>
        /// 选择钉盒模板时选中的钉子
        /// </summary>
        public List<Nail> TemplateNailList
        {
            get { return templateNailList; }
            set
            {
                templateNailList = value;
                if (templateNailList != null)
                {
                    TemplateNailMap = nailListToMap(templateNailList);
                }
            }
        }

        public static Dictionary<String, Nail> nailListToMap(List<Nail> templateNailList) { 
            return templateNailList.ToDictionary(p => String.Format(NAIL_MAP_KEY_FORMAT, p.area.code, p.point.X, p.point.Y), p => p);
        }

        /// <summary>
        /// 钉盒第一个原点-校准位置（x,y）
        /// </summary>
        public XYZ[] FixZeroLocations { get; set; }

        /// <summary>
        /// 计时器
        /// </summary>
        public Stopwatch Stopwatch { get; set; }
    }
}
